package com.cat.twoPointerTechnique;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/camelcase-matching/description/
 * @create 2025/8/7 10:23
 * @since JDK17
 */

public class Solution18 {
    public List<Boolean> camelMatch(String[] queries, String pattern) {
        List<Boolean> ans = new ArrayList<>();
        int n = queries.length, m = pattern.length();
        for (int i = 0, len; i < n; i++) {
            ans.add(judge(queries[i], queries[i].length(), pattern, m));
        }
        return ans;
    }

    public boolean judge(String s1, int n, String s2, int m) {
        int i, j;
        for (i = j = 0; i < m; i++) {
            while (j < n && s1.charAt(j) != s2.charAt(i)) j++;
            if (j == n) {   // 没找到
                return false;
            }
        }
        return true;
    }
}
